package audio;

import mllib.Classifier;
import java.lang.Thread;

public class AudioClassifier 
{
    private Classifier c;
    private AudioCapture01 ac1;

    public AudioClassifier(String filename)
    {
        c = new Classifier(filename, Classifier.NoReducer,  1500);
        ac1 = new AudioCapture01( "ERASEMEIFYOUSEEME");
        ac1.setVisible(false);
        ac1.startRecording();
        ac1.INVISIBLE = true;
        /*TODO other settings for ac1*/
    }


    public String classify( )
    {	
        String word = "other_other";
        double[] vector = null;
         
        while( (vector = ac1.getCurrVector()) == null)
          try{Thread.sleep(100);}catch(Exception e){e.printStackTrace();}
        
        word = c.identify(vector); 
        return word;
    }

    public void stopCapture() {
        ac1.setVisible(false);
        ac1.dispose();
    }




}
